package com.hiwan.unions.activity.system;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.hiwan.unions.R;
import com.hiwan.unions.activity.base.RootActivity;
import com.hiwan.unions.activity.system.eventFragment.AFragment;
import com.hiwan.unions.activity.system.eventFragment.BFragment;
import com.hiwan.unions.activity.system.eventFragment.CFragment;
import com.hiwan.unions.adapter.fragmentAdapters.MyFragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by llg on 2017/7/8.
 */
public class EventActivity extends RootActivity {
    private ArrayList<Fragment> listFragments;
    private String[] titles = new String[]{"未开始", "进行中", "已结束"};
    ViewPager viewPager;

    @Override
    protected int getLayout() {
        return R.layout.activity_news;
    }

    @Override
    protected void initData() {

    }


    @Override
    protected void onViewCreated() {
        super.onViewCreated();
        TabLayout tabLayout = findView(R.id.tabLayout);
        viewPager = findView(R.id.viewpager);
        listFragments = new ArrayList<Fragment>();
        listFragments.add(new AFragment());
        listFragments.add(new BFragment());
        listFragments.add(new CFragment());

        MyFragmentPagerAdapter adapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), this, titles, listFragments);
        //viewpager加载adapter
        viewPager.setAdapter(adapter);
        //TabLayout加载viewpager
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        tabLayout.setTabMode(TabLayout.MODE_FIXED);
        //设置欲缓存页
        viewPager.setOffscreenPageLimit(3);
        setTitleTxt("我的活动");
    }

}
